Skip to content

Commit

Permalink
d
Browse files Browse the repository at this point in the history
  • Loading branch information
sunrabbit123 committed Aug 13, 2023
1 parent 15251e2 commit 65a6bba
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 17 deletions.
12 changes: 12 additions & 0 deletions crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,18 @@ impl Analyzer<'_, '_> {
if results.iter().any(Result::is_ok) {
return Ok(());
}

if let Type::Param(TypeParam {
constraint: Some(box c), ..
}) = rhs
{
if let Ok(result) = self.normalize(Some(span), Cow::Borrowed(c), Default::default()) {
return self
.assign_with_opts(data, to, result.normalize(), opts)
.context("tried to assign a type_param at union");
}
}

let normalized = lu.types.iter().any(|ty| match ty.normalize() {
Type::TypeLit(ty) => ty.metadata.normalized,
_ => false,
Expand Down
19 changes: 19 additions & 0 deletions crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @strictNullChecks: true
// @declaration: true

class Shape {
name: string;
width: number;
height: number;
visible: boolean;
}

function getProperty<T, K extends keyof T>(obj: T, key: K) {
return obj[key];
}

function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
let name = getProperty(shape, "name");
let prop = getProperty(shape, key);
return prop;
}
1 change: 1 addition & 0 deletions crates/stc_ts_type_checker/tests/conformance.pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,7 @@ jsdoc/parseLinkTag.ts
jsdoc/parseThrowsTag.ts
jsdoc/seeTag1.ts
jsdoc/seeTag2.ts
jsdoc/typeParameterExtendsUnionConstraintDistributed.ts
jsx/tsxEmitSpreadAttribute.ts
moduleResolution/importFromDot.ts
moduleResolution/packageJsonImportsExportsOptionCompat.ts
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required_errors": {},
"required_error_lines": {},
"extra_errors": {
"TS2345": 10,
"TS2345": 9,
"TS2339": 2,
"TS0": 2,
"TS2322": 8
Expand All @@ -11,7 +11,6 @@
"TS2345": [
96,
132,
157,
162,
291,
295,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 5,
extra_error: 22,
extra_error: 21,
panic: 0,
}
2 changes: 1 addition & 1 deletion crates/stc_ts_type_checker/tests/tsc-stats.rust-debug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 3501,
matched_error: 6534,
extra_error: 765,
extra_error: 763,
panic: 73,
}

0 comments on commit 65a6bba

Please sign in to comment.