Closed
Description
TypeScript Version: 3.7.3
Search Terms:
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
const pageInfo = `page: 1/12 total: 234 `
const {
groups: { totalPage, count },
} = /page:1\/(?<totalPage>\d+).* total:(?<count>\d+) /.exec(pageInfo);
console.info({ totalPage, count })
tsconfig.json
{
"compilerOptions": {
// Target latest version of ECMAScript.
"target": "esnext",
// Search under node_modules for non-relative imports.
"moduleResolution": "node",
// Process & infer types from .js files.
"allowJs": true,
// Don't emit; allow Babel to transform files.
"noEmit": true,
// Enable strictest settings like strictNullChecks & noImplicitAny.
"strict": true,
// Disallow features that require cross-file information for emit.
"isolatedModules": true,
// Import non-ES modules as default imports.
"esModuleInterop": true,
// https://www.detroitlabs.com/blog/2018/02/28/adding-custom-type-definitions-to-a-third-party-library/
"typeRoots": [
"./@types",
"./node_modules/@types"
],
"lib": [
"esnext",
"es2018.regexp"
],
},
"include": [
"src",
"tools"
]
}
Expected behavior:
When run tsc, No error or warning shown
Actual behavior:
error TS2339: Property 'groups' does not exist on type 'RegExpExecArray | null'.
Playground Link:
http://www.typescriptlang.org/play/?target=99&ssl=1&ssc=1&pln=5&pc=35#
Related Issues:
#22082
Metadata
Metadata
Assignees
Labels
No labels