Skip to content

Error handling test #62219

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ jobs:
node-version: 'lts/*'
- run: npm ci

- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.cache/dprint
key: ${{ runner.os }}-dprint-${{ hashFiles('package-lock.json', '.dprint.jsonc') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
uses: github/codeql-action/init@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.5
with:
config-file: ./.github/codeql/codeql-configuration.yml
# Override language selection by uncommenting this and choosing your languages
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
uses: github/codeql-action/autobuild@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.5

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -70,4 +70,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
uses: github/codeql-action/analyze@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.5
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: 'Upload to code-scanning'
uses: github/codeql-action/upload-sarif@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.5
with:
sarif_file: results.sarif
3 changes: 3 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40789,6 +40789,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (checkForDisallowedESSymbolOperand(operator)) {
leftType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(leftType, left));
rightType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(rightType, right));
if (leftType.flags === TypeFlags.String && rightType.flags === TypeFlags.String) {
error(errorNode, Diagnostics.Cannot_compare_strings);
}
reportOperatorErrorUnless((left, right) => {
if (isTypeAny(left) || isTypeAny(right)) {
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8519,5 +8519,9 @@
"'{0}' is not a valid meta-property for keyword 'import'. Did you mean 'meta' or 'defer'?": {
"category": "Error",
"code": 18061
},
"Cannot compare strings": {
"category": "Error",
"code": 18062
}
}
8 changes: 3 additions & 5 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12026,7 +12026,7 @@ export function isSideEffectImport(node: Node): boolean {
return !!ancestor && !ancestor.importClause;
}

// require('module').builtinModules.filter(x => !x.startsWith('_'))
// require('module').builtinModules.filter(x => !x.match(/^(?:_|node:)/))
const unprefixedNodeCoreModulesList = [
"assert",
"assert/strict",
Expand Down Expand Up @@ -12069,7 +12069,6 @@ const unprefixedNodeCoreModulesList = [
"stream/web",
"string_decoder",
"sys",
"test/mock_loader",
"timers",
"timers/promises",
"tls",
Expand All @@ -12088,11 +12087,10 @@ const unprefixedNodeCoreModulesList = [
/** @internal */
export const unprefixedNodeCoreModules: Set<string> = new Set(unprefixedNodeCoreModulesList);

// await fetch('https://nodejs.org/docs/latest/api/all.json').then(r => r.text()).then(t =>
// new Set(t.match(/(?<=')node:.+?(?=')/g))
// .difference(new Set(require('module').builtinModules.map(x => `node:${x}`))))
// require('module').builtinModules.filter(x => x.startsWith('node:'))
/** @internal */
export const exclusivelyPrefixedNodeCoreModules: Set<string> = new Set([
"node:quic",
"node:sea",
"node:sqlite",
"node:test",
Expand Down
6 changes: 6 additions & 0 deletions tests/baselines/reference/stringComp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [tests/cases/compiler/stringComp.ts] ////

//// [stringComp.ts]


//// [stringComp.js]
Comment on lines +1 to +6
Copy link
Preview

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The baseline file references 'stringComp.ts' but the actual test file is named 'StringComp.ts', creating a mismatch that will cause test failures.

Suggested change
//// [tests/cases/compiler/stringComp.ts] ////
//// [stringComp.ts]
//// [stringComp.js]
//// [tests/cases/compiler/StringComp.ts] ////
//// [StringComp.ts]
//// [stringComp.js]

Copilot uses AI. Check for mistakes.

4 changes: 4 additions & 0 deletions tests/baselines/reference/stringComp.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//// [tests/cases/compiler/stringComp.ts] ////

=== stringComp.ts ===

4 changes: 4 additions & 0 deletions tests/baselines/reference/stringComp.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//// [tests/cases/compiler/stringComp.ts] ////

=== stringComp.ts ===

Comment on lines +1 to +4
Copy link
Preview

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The baseline file references 'stringComp.ts' but the actual test file is named 'StringComp.ts', creating a mismatch that will cause test failures.

Suggested change
//// [tests/cases/compiler/stringComp.ts] ////
=== stringComp.ts ===
//// [tests/cases/compiler/StringComp.ts] ////
=== stringComp.ts ===

Copilot uses AI. Check for mistakes.

Original file line number Diff line number Diff line change
Expand Up @@ -1330,38 +1330,6 @@ TI:: [hh:mm:ss:mss] Finished typings discovery:
]
}

ts.JsTyping.discoverTypings::
{
"fileNames": [
"/home/src/projects/project/app.js"
],
"projectRootPath": "/home/src/projects/project",
"safeList": {},
"packageNameToTypingLocation": {},
"typeAcquisition": {
"enable": true
},
"unresolvedImports": [
"test/mock_loader",
"somename"
],
"typesRegistry": {},
"compilerOptions": {}
}
TI:: [hh:mm:ss:mss] Inferred typings from unresolved imports: ["node","somename"]
TI:: [hh:mm:ss:mss] Finished typings discovery:
{
"cachedTypingPaths": [],
"newTypingNames": [
"node",
"somename"
],
"filesToWatch": [
"/home/src/projects/project/bower_components",
"/home/src/projects/project/node_modules"
]
}

ts.JsTyping.discoverTypings::
{
"fileNames": [
Expand Down Expand Up @@ -3102,7 +3070,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:test/mock_loader",
"node:timers",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3134,7 +3102,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:timers",
"node:timers/promises",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3166,7 +3134,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:timers/promises",
"node:tls",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3198,7 +3166,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:tls",
"node:trace_events",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3230,7 +3198,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:trace_events",
"node:tty",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3262,7 +3230,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:tty",
"node:url",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3294,7 +3262,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:url",
"node:util",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3326,7 +3294,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:util",
"node:util/types",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3358,7 +3326,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:util/types",
"node:v8",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3390,7 +3358,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:v8",
"node:vm",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3422,7 +3390,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:vm",
"node:wasi",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3454,7 +3422,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:wasi",
"node:worker_threads",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3486,7 +3454,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:worker_threads",
"node:zlib",
"somename"
],
"typesRegistry": {},
Expand Down Expand Up @@ -3518,7 +3486,7 @@ ts.JsTyping.discoverTypings::
"enable": true
},
"unresolvedImports": [
"node:zlib",
"node:quic",
"somename"
],
"typesRegistry": {},
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/compiler/stringComp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if ("bar" <= "foo") {
console.log("Really?")
}
Loading