Repository: TypeScript
Issue: Module resolution: Should error because of bad import, but TSC builds successfully. TSServer shows error in editor correctly.
Labels: Bug

### Demo Repo

https://github.com/jeffpalmeri/tsc-build-repro

### Which of the following problems are you reporting?

The module specifier resolves at build time, but shouldn't because it doesn't at runtime

### Demonstrate the defect described above with a code sample.

```
import { getContactSyncStatus } from "../refreshContactCRM/contactSync.service";

getContactSyncStatus();
```

### Run `tsc --showConfig` and paste its output here

```
{
    "compilerOptions": {
        "target": "es2016",
        "module": "commonjs",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "skipLibCheck": true,
        "allowSyntheticDefaultImports": true,
        "noImplicitAny": true,
        "noImplicitThis": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictBindCallApply": true,
        "strictPropertyInitialization": true,
        "alwaysStrict": true,
        "useUnknownInCatchVariables": true
    },
    "files": [
        "./src/lambdas/crms/crmProps/oneTableTrigger/oneTable.ts",
        "./src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service.ts"
    ],
    "include": [
        "src/**/*.ts"
    ]
}
```

### Run `tsc --traceResolution` and paste its output here

```
======== Resolving module '../refreshContactCRM/contactSync.service' from '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/oneTableTrigger/oneTable.ts'. ========
Module resolution kind is not specified, using 'Node10'.
Loading module as file / folder, candidate module location '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service', target file types: TypeScript, Declaration.
File name '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service' has a '.service' extension - stripping it.
File '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.d.service.ts' does not exist.
File '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service.ts' exists - use it as a name resolution result.
======== Module name '../refreshContactCRM/contactSync.service' was successfully resolved to '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service.ts'. ========
======== Resolving module '@typescript/lib-es2016' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2016.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016'
Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2016' was not resolved. ========
======== Resolving module '@typescript/lib-es2015' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015'
Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015' was not resolved. ========
======== Resolving module '@typescript/lib-es5' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es5' was not resolved. ========
======== Resolving module '@typescript/lib-decorators' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-decorators' was not resolved. ========
======== Resolving module '@typescript/lib-decorators/legacy' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/core' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.core.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/core'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/core'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/core'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/core'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/core'
Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/core' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/collection' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.collection.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/collection'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/collection'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/collection'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/collection'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/collection'
Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/collection' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/iterable' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.iterable.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/iterable'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/iterable'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/iterable'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/iterable'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/iterable'
Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/iterable' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/symbol' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.symbol.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol'
Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/symbol' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/generator' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.generator.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/generator'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/generator'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/generator'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/generator'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/generator'
Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/generator' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/promise' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.promise.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/promise'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/promise'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/promise'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/promise'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/promise'
Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/promise' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/proxy' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.proxy.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/proxy'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/proxy'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/proxy'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/proxy'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/proxy'
Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/proxy' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/reflect' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.reflect.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/reflect'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/reflect'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/reflect'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/reflect'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/reflect'
Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/reflect' was not resolved. ========
======== Resolving module '@typescript/lib-es2015/symbol-wellknown' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2015.symbol.wellknown.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'
Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2015/symbol-wellknown' was not resolved. ========
======== Resolving module '@typescript/lib-es2016/array-include' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2016.array.include.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/array-include'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/array-include'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/array-include'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/array-include'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/array-include'
Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2016/array-include' was not resolved. ========
======== Resolving module '@typescript/lib-es2016/intl' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.es2016.intl.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/intl'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/intl'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/intl'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/intl'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es2016/intl'
Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es2016/intl' was not resolved. ========
======== Resolving module '@typescript/lib-dom' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-dom' was not resolved. ========
======== Resolving module '@typescript/lib-webworker/importscripts' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========
======== Resolving module '@typescript/lib-scripthost' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-scripthost' was not resolved. ========
======== Resolving module '@typescript/lib-dom/iterable' from '/Users/jpalmeri/Documents/tsbuild-repro/__lib_node_modules_lookup_lib.dom.iterable.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom/iterable'
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom/iterable'
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom/iterable'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom/iterable'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom/iterable'
Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/Users/jpalmeri/Documents/tsbuild-repro/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jpalmeri/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-dom/iterable' was not resolved. ========

```

### Paste the `package.json` of the *importing* module, if it exists

```
{
  "name": "tsbuild-repro",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {}
}
```

### Paste the `package.json` of the *target* module, if it exists

```
{
  "name": "tsbuild-repro",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {}
}
```

### Any other comments can go here

To summarize the issue I'm seeing: TSC is compiling the code successfully without showing any errors, even though there is an import error that TSServer is correctly detecting and showing in the editor diagnostics ("Cannot find module '../refreshContactCRM/contactSync.service' or its corresponding type declarations. [2307]"). There is a symlink in the project that seems to be related to why this issue is occurring.

Actual behavior: TSC runs with no errors and produces a .js file that throws a MODULE_NOT_FOUND error when run.
Expected behavior: TSC throws error when building (that is reflected by the diagnostic TSServer error shows in editor).

TSC version: Version 5.4.3

This is the project tree structure:
```
├── package-lock.json
├── package.json
├── src
│   └── lambdas
│       ├── crms
│       │   └── crmProps
│       │       ├── oneTableTrigger -> ../../oneTableTrigger     // Note the symlink here
│       │       └── refreshContactCRM
│       │           └── contactSync.service.ts
│       └── oneTableTrigger
│           └── oneTable.ts
└── tsconfig.json
```

In the file src/lambdas/oneTableTrigger/oneTable.ts, there is a bad import:

`import { getContactSyncStatus } from "../refreshContactCRM/contactSync.service";`

The path does not lead to any file, and there is a correct diagnostic message shown in the editor telling me such. But running `tsc` the code compiles with no errors or warnings, producing a js file with this corresponding require: 

`const contactSync_service_1 = require("../refreshContactCRM/contactSync.service");`

Which errors when it is run because of this:
```
-> node ./src/lambdas/oneTableTrigger/oneTable.js

-> Error: Cannot find module '../refreshContactCRM/contactSync.service'
Require stack:
- /Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/oneTableTrigger/oneTable.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/oneTableTrigger/oneTable.js:3:31)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/oneTableTrigger/oneTable.js'
  ]
}
```

I see unexpected module resolution when I inspect the output of `tsc --traceResolution` that I don't understand, and am thinking that it could be a good clue on the source of the problem. Specifically here:

```
======== Resolving module '../refreshContactCRM/contactSync.service' from '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/oneTableTrigger/oneTable.ts'. ========
Module resolution kind is not specified, using 'Node10'.
Loading module as file / folder, candidate module location '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service', target file types: TypeScript, Declaration.
File name '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service' has a '.service' extension - stripping it.
File '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.d.service.ts' does not exist.
File '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service.ts' exists - use it as a name resolution result.
======== Module name '../refreshContactCRM/contactSync.service' was successfully resolved to '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service.ts'. ========
```

Specifically on the 3rd line of that traceResolution output:

`Loading module as file / folder, candidate module location '/Users/jpalmeri/Documents/tsbuild-repro/src/lambdas/crms/crmProps/refreshContactCRM/contactSync.service', target file types: TypeScript, Declaration.
`

The candidate module location is a real path, but I don't understand why or how it was picked as a candidate location, and this part seems like an error to me. If you manually follow the path from the import in the importing file, it looks like this: 
From `src/lambdas/oneTableTrigger/oneTable.ts`:

`import { getContactSyncStatus } from "../refreshContactCRM/contactSync.service";`

What I would expect would be this:
-> `src/lambdas/refreshContactCRM/contactSync.service.ts` (which is not a real path, no file at this location)

There is something about the symlink being present that is causing this behavior, but it's not something I can explain or understand. It's as if the module resolution process is getting that candidate path from a symlink path, even though the file that is doing the importing is not a symlink, nor importing from a symlink location. It's a just a normal real file doing a normal relative import is what it looks like to me.

If I delete the symlink:

`rm ./src/lambdas/crms/crmProps/oneTableTrigger`

I get the same exact diagnostic error message in my editor, but running `tsc` fails with the expected behavior:

```
src/lambdas/oneTableTrigger/oneTable.ts:1:38 - error TS2307: Cannot find module '../refreshContactCRM/contactSync.service' or its corresponding type declarations.

1 import { getContactSyncStatus } from "../refreshContactCRM/contactSync.service";
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in src/lambdas/oneTableTrigger/oneTable.ts:1
```

When the symlink is present, it's as if the module resolution is choosing the candidate path just because there is a symlink present, even though the that's not the actual direction of the symlink, it's the reverse. And again, the file doing the importing here is not a symlink (the symlink in the project points to the directory that that the importing file is in), nor is it importing from a symlink. So when I try to follow the logic of the import, even with the presence of this symlink, it does not make sense to me.

Just a couple more notes:

I've tried adding the tsconfig option `preserveSymlinks` as both true and false, but that causes no difference. The outputs of `--traceResolution` are exactly the same for both, and exactly the same as not including the option at all (as it is originally in the repo I provided)

If you delete the symlink, you can add it back with this:

`ln -s ../../oneTableTrigger ./src/lambdas/crms/crmProps/oneTableTrigger`

And my last important thought: The module resolution feels like the bug to me here, but even if it is actually the correct behavior for an explainable reason, then it seems like a bug that there is a mismatch between what TSC produces and TSServer is telling me. The TSServer diagnostic message is showing me the correct error, and reflects the runtime error you receive when trying to run the produced javascript file, but TSC does not reflect that when it builds.