-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Set impliedNodeFormat on sourceFile we get from host to ensure the field is set correctly #50977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
05d739b
Add test that fails
sheetalkamat c8ebfb8
Handle impliedNodeFormat when handling sourceFileCache
sheetalkamat 5c98b9c
Revert the fix
sheetalkamat 651a47f
Make sure impliedNodeFormat is set for the sourceFile
sheetalkamat 2c22989
Revert "Make sure impliedNodeFormat is set for the sourceFile"
sheetalkamat 92bf32d
Revert "Revert the fix"
sheetalkamat 5f7bc05
Merge branch 'main' into tsBuildImpliedNodeFormat
sheetalkamat 4bd8b9b
Swap the keys for map
sheetalkamat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
...ce/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
Input:: | ||
//// [/lib/lib.d.ts] | ||
/// <reference no-default-lib="true"/> | ||
interface Boolean {} | ||
interface Function {} | ||
interface CallableFunction {} | ||
interface NewableFunction {} | ||
interface IArguments {} | ||
interface Number { toExponential: any; } | ||
interface Object {} | ||
interface RegExp {} | ||
interface String { charAt: any; } | ||
interface Array<T> { length: number; [n: number]: T; } | ||
interface ReadonlyArray<T> {} | ||
declare const console: { log(msg: any): void; }; | ||
|
||
//// [/lib/lib.es2022.full.d.ts] | ||
/// <reference no-default-lib="true"/> | ||
interface Boolean {} | ||
interface Function {} | ||
interface CallableFunction {} | ||
interface NewableFunction {} | ||
interface IArguments {} | ||
interface Number { toExponential: any; } | ||
interface Object {} | ||
interface RegExp {} | ||
interface String { charAt: any; } | ||
interface Array<T> { length: number; [n: number]: T; } | ||
|
||
//// [/src/projects/a/src/index.ts] | ||
|
||
|
||
//// [/src/projects/a/tsconfig.json] | ||
{"compilerOptions":{"strict":true}} | ||
|
||
//// [/src/projects/b/package.json] | ||
{"name":"b","type":"module"} | ||
|
||
//// [/src/projects/b/src/index.ts] | ||
import pg from "pg"; | ||
pg.foo(); | ||
|
||
|
||
//// [/src/projects/b/tsconfig.json] | ||
{"compilerOptions":{"strict":true,"module":"node16"}} | ||
|
||
//// [/src/projects/node_modules/@types/pg/index.d.ts] | ||
export function foo(): void; | ||
|
||
//// [/src/projects/node_modules/@types/pg/package.json] | ||
{"name":"@types/pg","types":"index.d.ts"} | ||
|
||
|
||
|
||
Output:: | ||
/lib/tsc -b /src/projects/a /src/projects/b --verbose --traceResolution --explainFiles | ||
[[90m12:00:22 AM[0m] Projects in this build: | ||
* src/projects/a/tsconfig.json | ||
* src/projects/b/tsconfig.json | ||
|
||
[[90m12:00:23 AM[0m] Project 'src/projects/a/tsconfig.json' is out of date because output file 'src/projects/a/src/index.js' does not exist | ||
|
||
[[90m12:00:24 AM[0m] Building project '/src/projects/a/tsconfig.json'... | ||
|
||
======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/node_modules/@types'. ======== | ||
Resolving with primary search path '/src/projects/node_modules/@types'. | ||
Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. | ||
'package.json' does not have a 'typesVersions' field. | ||
'package.json' does not have a 'typings' field. | ||
'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
File '/src/projects/node_modules/@types/pg/index.d.ts' exist - use it as a name resolution result. | ||
Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== | ||
lib/lib.d.ts | ||
Default library for target 'es3' | ||
src/projects/a/src/index.ts | ||
Matched by default include pattern '**/*' | ||
src/projects/node_modules/@types/pg/index.d.ts | ||
Entry point for implicit type library 'pg' | ||
[[90m12:00:26 AM[0m] Project 'src/projects/b/tsconfig.json' is out of date because output file 'src/projects/b/src/index.js' does not exist | ||
|
||
[[90m12:00:27 AM[0m] Building project '/src/projects/b/tsconfig.json'... | ||
|
||
File '/src/projects/b/src/package.json' does not exist. | ||
Found 'package.json' at '/src/projects/b/package.json'. | ||
'package.json' does not have a 'typesVersions' field. | ||
======== Resolving module 'pg' from '/src/projects/b/src/index.ts'. ======== | ||
Module resolution kind is not specified, using 'Node16'. | ||
Resolving in ESM mode with conditions 'node', 'import', 'types'. | ||
File '/src/projects/b/src/package.json' does not exist according to earlier cached lookups. | ||
File '/src/projects/b/package.json' exists according to earlier cached lookups. | ||
Loading module 'pg' from 'node_modules' folder, target file type 'TypeScript'. | ||
Directory '/src/projects/b/src/node_modules' does not exist, skipping all lookups in it. | ||
Directory '/src/projects/b/node_modules' does not exist, skipping all lookups in it. | ||
File '/src/projects/node_modules/@types/pg/package.json' exists according to earlier cached lookups. | ||
'package.json' does not have a 'typings' field. | ||
'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
File '/src/projects/node_modules/@types/pg/index.d.ts' exist - use it as a name resolution result. | ||
Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
======== Module name 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts'. ======== | ||
File '/src/projects/node_modules/@types/pg/package.json' exists according to earlier cached lookups. | ||
======== Resolving type reference directive 'pg', containing file '/src/projects/b/__inferred type names__.ts', root directory '/src/projects/node_modules/@types'. ======== | ||
Resolving with primary search path '/src/projects/node_modules/@types'. | ||
File '/src/projects/node_modules/@types/pg/package.json' exists according to earlier cached lookups. | ||
'package.json' does not have a 'typings' field. | ||
'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
File '/src/projects/node_modules/@types/pg/index.d.ts' exist - use it as a name resolution result. | ||
Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. | ||
======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== | ||
File '/lib/package.json' does not exist. | ||
File '/package.json' does not exist. | ||
lib/lib.es2022.full.d.ts | ||
Default library for target 'es2022' | ||
src/projects/node_modules/@types/pg/index.d.ts | ||
Imported via "pg" from file 'src/projects/b/src/index.ts' | ||
Entry point for implicit type library 'pg' | ||
File is CommonJS module because 'src/projects/node_modules/@types/pg/package.json' does not have field "type" | ||
src/projects/b/src/index.ts | ||
Matched by default include pattern '**/*' | ||
File is ECMAScript module because 'src/projects/b/package.json' has field "type" with value "module" | ||
exitCode:: ExitStatus.Success | ||
|
||
|
||
//// [/src/projects/a/src/index.js] | ||
"use strict"; | ||
|
||
|
||
//// [/src/projects/b/src/index.js] | ||
import pg from "pg"; | ||
pg.foo(); | ||
|
||
|
||
|
||
|
||
Change:: no-change-run | ||
Input:: | ||
|
||
|
||
Output:: | ||
/lib/tsc -b /src/projects/a /src/projects/b --verbose --traceResolution --explainFiles | ||
[[90m12:00:29 AM[0m] Projects in this build: | ||
* src/projects/a/tsconfig.json | ||
* src/projects/b/tsconfig.json | ||
|
||
[[90m12:00:30 AM[0m] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/a/src/index.js' | ||
|
||
[[90m12:00:31 AM[0m] Project 'src/projects/b/tsconfig.json' is up to date because newest input 'src/projects/b/src/index.ts' is older than output 'src/projects/b/src/index.js' | ||
|
||
exitCode:: ExitStatus.Success | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.