Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast.
}

func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic {
return SortAndDeduplicateDiagnostics(slices.Concat(p.programDiagnostics, p.includeProcessor.getDiagnostics(p).GetDiagnostics()))
return SortAndDeduplicateDiagnostics(slices.Concat(
p.programDiagnostics,
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics()))
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics(),
))

Nit (sorry)

}

func (p *Program) getSourceFilesToEmit(targetSourceFile *ast.SourceFile, forceDtsEmit bool) []*ast.SourceFile {
Expand Down Expand Up @@ -1024,7 +1026,8 @@ func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, so
fileChecker, done = p.checkerPool.GetCheckerForFile(ctx, sourceFile)
defer done()
}
diags := slices.Clip(sourceFile.BindDiagnostics())
diags := slices.Clip(p.includeProcessor.getDiagnostics(p).GetDiagnosticsForFile(sourceFile.FileName()))
diags = append(diags, sourceFile.BindDiagnostics()...)
checkers, closeCheckers := p.checkerPool.GetAllCheckers(ctx)
defer closeCheckers()

Expand Down
2 changes: 1 addition & 1 deletion internal/execute/tsctests/tscbuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func TestBuildDemoProject(t *testing.T) {
commandLineArgs: []string{"--b", "--verbose"},
},
{
// !!! sheetal - this has missing errors from strada about files not in rootDir (3) and value is declared but not used (1)
// !!! sheetal - this has missing errors from strada about files not in rootDir (3)
subScenario: "in bad-ref branch reports the error about files not in rootDir at the import location",
files: getBuildDemoFileMap(func(files FileMap) {
files["/user/username/projects/demo/core/utilities.ts"] = `import * as A from '../animals'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//// [tests/cases/compiler/processingDiagnosticSkipLibCheck.ts] ////

//// [index.d.ts]
/// <reference types="cookie-session"/>
export const foo = 1;

//// [package.json]
{
"name": "foo",
"version": "1.0.0",
"types": "index.d.ts"
}
//// [index.ts]
import { foo } from 'foo';
const y = foo;


//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const foo_1 = require("foo");
const y = foo_1.foo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/processingDiagnosticSkipLibCheck.ts] ////

=== /index.ts ===
import { foo } from 'foo';
>foo : Symbol(foo, Decl(index.ts, 0, 8))

const y = foo;
>y : Symbol(y, Decl(index.ts, 1, 5))
>foo : Symbol(foo, Decl(index.ts, 0, 8))

=== /node_modules/foo/index.d.ts ===
/// <reference types="cookie-session"/>
export const foo = 1;
>foo : Symbol(foo, Decl(index.d.ts, 1, 12))

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//// [tests/cases/compiler/processingDiagnosticSkipLibCheck.ts] ////

=== /index.ts ===
import { foo } from 'foo';
>foo : 1

const y = foo;
>y : 1
>foo : 1

=== /node_modules/foo/index.d.ts ===
/// <reference types="cookie-session"/>
export const foo = 1;
>foo : 1
>1 : 1

Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ Output::
4 import { createDog, Dog } from './dog';
   ~~~~~~~

core/utilities.ts:1:13 - error TS6133: 'A' is declared but its value is never read.

1 import * as A from '../animals'
   ~

core/utilities.ts:1:20 - error TS6307: File '/user/username/projects/demo/animals/index.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern.
The file is in the program because:
Imported via '../animals' from file '/user/username/projects/demo/core/utilities.ts'
Expand All @@ -154,11 +159,11 @@ Output::
[HH:MM:SS AM] Building project 'zoo/tsconfig.json'...


Found 3 errors in 2 files.
Found 4 errors in 2 files.

Errors Files
2 animals/index.ts:1
1 core/utilities.ts:1
2 core/utilities.ts:1

//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
/// <reference no-default-lib="true"/>
Expand Down Expand Up @@ -395,11 +400,10 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function ()
"size": 2794
}
//// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] *new*
{"version":"FakeTSVersion","errors":true,"root":[5],"fileNames":["lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"47f086fff365b1e8b96a6df2c4313c1a-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}","signature":"1d76529d4652ddf9ebdfa65e748240fb-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedNodeFormat":1},{"version":"39dbb9b755eef022e56879989968e5cf-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}","signature":"4dc4bc559452869bfd0d92b5ed5d604f-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedNodeFormat":1},{"version":"d6a6b65b86b0330b1a1bd96b1738d5a4-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };","signature":"a3e41a5ccafc3d07a201f0603e28edcf-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","impliedNodeFormat":1},{"version":"c71a99e072793c29cda49dd3fea04661-import * as A from '../animals'\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf<T>(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}","signature":"096c311e7aecdb577f7b613fbf1716e5-export declare function makeRandomName(): string;\nexport declare function lastElementOf<T>(arr: T[]): T | undefined;\n","impliedNodeFormat":1}],"fileIdsList":[[4,5],[2,3],[4]],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,5],"latestChangedDtsFile":"./utilities.d.ts"}
{"version":"FakeTSVersion","root":[5],"fileNames":["lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"47f086fff365b1e8b96a6df2c4313c1a-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}","signature":"1d76529d4652ddf9ebdfa65e748240fb-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedNodeFormat":1},{"version":"39dbb9b755eef022e56879989968e5cf-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}","signature":"4dc4bc559452869bfd0d92b5ed5d604f-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedNodeFormat":1},{"version":"d6a6b65b86b0330b1a1bd96b1738d5a4-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };","signature":"a3e41a5ccafc3d07a201f0603e28edcf-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","impliedNodeFormat":1},{"version":"c71a99e072793c29cda49dd3fea04661-import * as A from '../animals'\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf<T>(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}","signature":"096c311e7aecdb577f7b613fbf1716e5-export declare function makeRandomName(): string;\nexport declare function lastElementOf<T>(arr: T[]): T | undefined;\n","impliedNodeFormat":1}],"fileIdsList":[[4,5],[2,3],[4]],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[[4,[{"pos":19,"end":29,"code":6307,"category":1,"message":"File '/user/username/projects/demo/animals/animal.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern."},{"pos":86,"end":93,"code":6307,"category":1,"message":"File '/user/username/projects/demo/animals/dog.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern."}]],[5,[{"pos":12,"end":13,"code":6133,"category":1,"message":"'A' is declared but its value is never read.","reportsUnnecessary":true},{"pos":19,"end":31,"code":6307,"category":1,"message":"File '/user/username/projects/demo/animals/index.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern.","messageChain":[{"noFile":true,"pos":-1,"end":-1,"code":1430,"category":3,"message":"The file is in the program because:","messageChain":[{"noFile":true,"pos":-1,"end":-1,"code":1393,"category":3,"message":"Imported via '../animals' from file '/user/username/projects/demo/core/utilities.ts'"},{"noFile":true,"pos":-1,"end":-1,"code":1393,"category":3,"message":"Imported via '.' from file '/user/username/projects/demo/animals/dog.ts'"}]}],"relatedInformation":[{"file":3,"pos":19,"end":22,"code":1399,"category":3,"message":"File is included via import here."}]}]]],"latestChangedDtsFile":"./utilities.d.ts"}
//// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
{
"version": "FakeTSVersion",
"errors": true,
"root": [
{
"files": [
Expand Down Expand Up @@ -513,14 +517,86 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function ()
]
},
"semanticDiagnosticsPerFile": [
"lib.d.ts",
"../../animals/animal.ts",
"../../animals/dog.ts",
"../../animals/index.ts",
"../../core/utilities.ts"
[
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell, these new errors are correct and show up in the Strada baselines for these tests.

"../../animals/index.ts",
[
{
"pos": 19,
"end": 29,
"code": 6307,
"category": 1,
"message": "File '/user/username/projects/demo/animals/animal.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern."
},
{
"pos": 86,
"end": 93,
"code": 6307,
"category": 1,
"message": "File '/user/username/projects/demo/animals/dog.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern."
}
]
],
[
"../../core/utilities.ts",
[
{
"pos": 12,
"end": 13,
"code": 6133,
"category": 1,
"message": "'A' is declared but its value is never read.",
"reportsUnnecessary": true
},
{
"pos": 19,
"end": 31,
"code": 6307,
"category": 1,
"message": "File '/user/username/projects/demo/animals/index.ts' is not listed within the file list of project '/user/username/projects/demo/core/tsconfig.json'. Projects must list all files or use an 'include' pattern.",
"messageChain": [
{
"noFile": true,
"pos": -1,
"end": -1,
"code": 1430,
"category": 3,
"message": "The file is in the program because:",
"messageChain": [
{
"noFile": true,
"pos": -1,
"end": -1,
"code": 1393,
"category": 3,
"message": "Imported via '../animals' from file '/user/username/projects/demo/core/utilities.ts'"
},
{
"noFile": true,
"pos": -1,
"end": -1,
"code": 1393,
"category": 3,
"message": "Imported via '.' from file '/user/username/projects/demo/animals/dog.ts'"
}
]
}
],
"relatedInformation": [
{
"file": "../../animals/dog.ts",
"pos": 19,
"end": 22,
"code": 1399,
"category": 3,
"message": "File is included via import here."
}
]
}
]
]
],
"latestChangedDtsFile": "./utilities.d.ts",
"size": 3178
"size": 4652
}
//// [/user/username/projects/demo/lib/core/utilities.d.ts] *new*
export declare function makeRandomName(): string;
Expand Down Expand Up @@ -658,11 +734,11 @@ function createZoo() {

core/tsconfig.json::
SemanticDiagnostics::
*not cached* /home/src/tslibs/TS/Lib/lib.d.ts
*not cached* /user/username/projects/demo/animals/animal.ts
*not cached* /user/username/projects/demo/animals/dog.ts
*not cached* /user/username/projects/demo/animals/index.ts
*not cached* /user/username/projects/demo/core/utilities.ts
*refresh* /home/src/tslibs/TS/Lib/lib.d.ts
*refresh* /user/username/projects/demo/animals/animal.ts
*refresh* /user/username/projects/demo/animals/dog.ts
*refresh* /user/username/projects/demo/animals/index.ts
*refresh* /user/username/projects/demo/core/utilities.ts
Signatures::
(stored at emit) /user/username/projects/demo/animals/animal.ts
(stored at emit) /user/username/projects/demo/animals/dog.ts
Expand Down
Loading
Loading