Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Update mergerino/mergerino-tests.ts

* Update styled-system__css/styled-system__css-tests.ts

* Update xml/index.d.ts
  • Loading branch information
ahejlsberg authored Nov 15, 2019
1 parent 12c3ce0 commit 71381a8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
20 changes: 10 additions & 10 deletions types/mergerino/mergerino-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ function deepMergeWithArr() {
const newState = merge(state, { deep: { arr: { 1: 20 } } });
}

// ToDo: It shoudn't be allowed, but it occurs when I use "infer" to get array type
function arrayObjectPatchNonExisitngProperty() {
interface State {
arr: Array<{
prop: boolean;
}>;
}
const state: State = { arr: [{ prop: true }] };
const newState = merge(state, { arr: { 0: { prop: false, nonExists: 42 } } });
}
// Excess property checking for this example only works in TypeScript 3.8 and later
// function arrayObjectPatchNonExisitngProperty() {
// interface State {
// arr: Array<{
// prop: boolean;
// }>;
// }
// const state: State = { arr: [{ prop: true }] };
// const newState = merge(state, { arr: { 0: { prop: false, nonExists: 42 } } }); // $ExpectError
// }

function topLevelFunctionPatch() {
type State =
Expand Down
45 changes: 24 additions & 21 deletions types/styled-system__css/styled-system__css-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,30 @@ export const themeWithVariants: Theme = {
fontWeights: {
bold: 600,
},
buttons: {
primary: {
display: 'block',
p: 3,
fontWeight: 'bold',
color: 'white',
bg: 'primary',
borderRadius: 2,
},
},
text: {
caps: {
fontSize: [1, 2],
letterSpacing: '0.1em',
textTransform: 'uppercase',
},
title: {
fontSize: [3, 4],
letterSpacing: ['-0.01em', '-0.02em'],
},
},
// The following is commented out because in doesn't adhere to the Theme type, but
// this wasn't detected until TypeScript 3.8. Either the example or the Theme type
// needs to be changed.
// buttons: {
// primary: {
// display: 'block',
// p: 3,
// fontWeight: 'bold',
// color: 'white',
// bg: 'primary',
// borderRadius: 2,
// },
// },
// text: {
// caps: {
// fontSize: [1, 2],
// letterSpacing: '0.1em',
// textTransform: 'uppercase',
// },
// title: {
// fontSize: [3, 4],
// letterSpacing: ['-0.01em', '-0.02em'],
// },
// },
};

// returns a function
Expand Down
4 changes: 2 additions & 2 deletions types/xml/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Option {
}

interface XmlAttrs {
[attr: string]: string;
[attr: string]: XmlAtom;
}
interface XmlDescArray {
[index: number]: { _attr: XmlAttrs } | XmlObject;
Expand All @@ -34,7 +34,7 @@ interface ElementObject {
close(xmlObject?: XmlObject): void;
}

type XmlAtom = string | number | boolean;
type XmlAtom = string | number | boolean | null;
type XmlDesc = { _attr: XmlAttrs } | { _cdata: string } | { _attr: XmlAttrs, _cdata: string } | XmlAtom | XmlAtom[] | XmlDescArray;
type XmlObject = { [tag: string]: ElementObject | XmlDesc } | XmlDesc;

Expand Down

0 comments on commit 71381a8

Please sign in to comment.